package com.pengpai.pangucms.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pengpai.pangucms.entity.WebConfig;
import com.pengpai.pangucms.service.IWebConfigService;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/webStatic")
public class webStaticController {

    @Autowired
    private IWebConfigService webConfigService;

    @GetMapping("/index")
    public String  index(Model model){

        QueryWrapper<WebConfig> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("DISTINCT config_code").lambda();
        List<WebConfig> webConfigs = webConfigService.getBaseMapper().selectList(queryWrapper);
        List<String> list = new ArrayList<>();
        for(WebConfig webConfig:webConfigs){
            list.add(webConfig.getConfigCode());
        }
        model.addAttribute("list",list);

        return "admin/web_static/web_static_index";
    }
}
